<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<span id="pay">支付</span>
<script>
    function onBridgeReady(){
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId": "wxd65849ebe359e61e",     //公众号名称，由商户传入
                "timeStamp": "1564623733",         //时间戳，自1970年以来的秒数
                "nonceStr": "f8d333ac5dea4cc39d6ac83d00f4ab29", //随机串
                "package": "prepay_id=wx01094213687528c201b25ef01844265700",
                "signType": "RSA",         //微信签名方式：
                "paySign": "ItQMj+PRhROgChYncb4KVou02OHsp02tBCzlT/yhQiBCE/ACqaJ9M/vVyREApkiltFTwIcUK4vFWcvWCVUy3KO0Fv1bSr1ipkt0vi6V1eRrAq3EmevEdSR8e0nZSLlw/Zu5rPqqIR/0LeprNnykqJ4uGEBSTavb8rgoft+kREblXLFQDJIwzt7bgYwtWKZxLKq0T6XAwHI3z2zIichU9EDD9LLaFiapYGpkLiatDUUg6wwzsar6+fiINvtSj7XPUHjnO6sR5BiNCkf49eHCe/tDUFsqMHXzeL23rtbbGnyC0M9OcGPMyYLQuAmftRZf3WJnhGppxm0KME7lUfKJsjg==" //微信签名
            },
            function(res){
                if(res.err_msg == "get_brand_wcpay_request:ok" ){
                    // 使用以上方式判断前端返回,微信团队郑重提示：
                    //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                }
            });
    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }
</script>
</body>
</html>